package com.example.jinzproduct.controller;

import com.example.commons.utils.ApiResult;
import com.example.commons.utils.JWTUtil;
import com.example.jinzproduct.RedisUtil.RedisUtil;
import com.example.jinzproduct.server.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.concurrent.TimeUnit;

@RestController
@RequestMapping("/jinZhiIndex/jinZhiProduct")
public class JzTest {
    @Autowired
    private UserService userService;
    @Resource
    private RedisUtil redisUtil;
    @GetMapping("/test")
    public String test(String day){
        JWTUtil.getUser();
        return day;
    }

    @GetMapping("/gettestxzy")
    ApiResult<?> gettestxzy() {


        return ApiResult.success();
    }


    //查询某一天注册人数
    @GetMapping("/testDemo/{day}")
    public String countRegister(@PathVariable("day") String day){
        return day;
    };

    @GetMapping("/testList")
    public Object testList(){

        return userService.list();
    };

    //查询某一天注册人数
    @GetMapping("/testLis1t")
    public Object testLis1t(){
        return userService.list1(new HashMap());
    };


    //查询某一天注册人数
    @GetMapping("/redisTest")
    public void redisTest(){

        System.out.println( "第一次调用："+   redisUtil.get("17373841816redis") );
     boolean b=   redisUtil.set("xzy",11,300);

        System.out.println( "第一次调用："+   redisUtil.get("xzy") );

    };



}
